package day12.dat12;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        Map<Integer,String>map=new HashMap<>();
        map.put(1,"java");
        map.put(2,"python");
        map.put(1,"mysql");
        map.put(3,"oracle");
        map.put(4,"redis");
        System.out.println(map.size());
        System.out.println(map.get(2));



        Set<Integer> keySets=map.keySet();
        Iterator<Integer> iter=keySets.iterator();
        while (iter.hasNext()){
            Integer key=iter.next();
            String value=map.get(key);
            System.out.println(key+"->"+value);
            System.out.println(map);

            System.out.println("=====");


            Set<Map.Entry<Integer,String>> entrySets=map.entrySet();
            Iterator<Map.Entry<Integer,String>>entryIter=entrySets.iterator();
            while (entryIter.hasNext()){
                Map.Entry<Integer,String>entry=entryIter.next();
                System.out.println(entry.getKey()+":"+entry.getValue());
            }
        }

    }
}
